<template>
	<view class="content-box">
		<form-render
			mode="MOBILE"
			class="form-design"
			ref="form"
			:forms="filterformItem"
			:value="data.formData"
		/>
	</view>
</template>

<script>
import FormRender from '@/subPackagesIndex/components/approve-item/formRender/formRender.vue'
export default {
	components: { FormRender },
	props: {
		data: {
			type: Object,
			value: {},
		},
	},
	data() {
		return {}
	},
	computed: {
		filterformItem() {
			const arr = []
			this.data.formItems.forEach((item) => {
				if (
					![
						'TJGJ_YY',
						'TJGJ_SPD',
						'TJGJ_CW',
						'TJGJ_SK',
						'TJGJ_YY2',
					].includes(item.name) &&
					(this.data.formData[item.id] !== '' ||
						this.data.formData[item.id] === 0 ||
						(this.data.formData[item.id] &&
							this.data.formData[item.id].length === 0))
				) {
					arr.push(item)
				}
			})
			return arr && arr.length > 3 ? arr.slice(0, 3) : arr
		},
	},
	methods: {
		isShow(value) {
			const data = this.data.formData[value.id]
			if (!data) {
				return false
			} else {
				return true
			}
		},
		//内容展示
		filterContent(labelValue, contentVal) {
			if (contentVal || (contentVal && contentVal.length > 0)) {
				switch (labelValue) {
					case 'TimeRangePicker': {
						const newArr = contentVal.map((i) =>
							i.replace(/-/g, '/').substr(0, 16)
						)
						return newArr.join('-')
					}
					case 'DateTimeRange': {
						const newArr = contentVal.map((i) =>
							i.replace(/-/g, '/').substr(0, 16)
						)
						return newArr.join('-')
					}
					case 'ImageUpload': {
						return (
							contentVal &&
							contentVal.length > 0 &&
							contentVal.map((i) => i.url)
						)
					}
					case 'AmountInput': {
						return contentVal + '元'
					}
					default:
						return contentVal
				}
			}
		},
	},
}
</script>

<style scoped lang="scss">
.content-box {
	margin: 16rpx 0;
}
/deep/.form-design {
	.uni-forms-item {
		margin-bottom: 0rpx !important;
	}
}
</style>
